<template>
  <div class="label-container">
    <div class="label-title">{{title}}</div>
    <div class="label-wrap">
      <span
        v-for="label in labels"
        :key="label.tagId"
        :class="{'active': label.tagName === value}"
        @click="onLabelSelect(label)">{{label.tagName}}
      </span>
    </div>
  </div>
</template>
<script>

// import { getNoticeList, createNotice, deleteNotice } from '../../api';

export default {
  name: 'LabelCard',
  components: {},
  props: {
    value: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    labels: {
      type: Array,
      default: () => []
    },
    category: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    return {};
  },
  computed: {
    
  },
  methods: {
    onLabelSelect(label) {
      if (this.value === label.tagName) {
        this.$emit('input', '');
        this.$emit('change', this.category, {});
      } else {
        this.$emit('input', label.tagName);
        this.$emit('change', this.category, label);
      }
    }
  },
  mounted() {
   
  },
  beforeDestroy() {
    
  },
}
</script>

<style lang="scss" scoped>
  .label-container {
    background-color: #fff;
    border-radius: 5px;
    overflow: hidden;

    .label-title {
      font-size: 16px;
      font-weight: bold;
      padding: 0 16px;
      line-height: 40px;
      border-bottom: 1px solid #f0f0f0;
    }

    .label-wrap {
      padding-left: 8px;
      padding-top: 8px;
    }

    span {
      display: inline-block;
      vertical-align: top;
      padding: 4px 8px;
      border-radius: 3px;
      margin-right: 8px;
      margin-bottom: 8px;
      border: 1px solid  #c2e7b0;
      color: #67c23a;
      background-color: #fff;
      cursor: pointer;
    }

    span:hover {
      background-color: #f0f9eb;
    }

    span.active {
      color: #fff;
      background-color: #009a61;
      border-color: #009a61;
    }
  }
</style>
